/*
Kiwi Editor is a framework for building WYSIWYG web editors.
Copyright (C) 2011  Roosevelt de Lima Sardinha

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Contact the author at roosevelt1@gmail.com (Roosevelt) 
*/

/* CheckboxEO */
function checkboxEO(){	
    this.showProperties = function(){
	   this.tabId = this.propertyBox.addTab("Checkbox");
  	   this.propertyBox.addProperty(this.tabId, 0, 0, 'name', 'Textbox', this, {
	   		label: 'Name',
			help: 'Sets an identifier of the checkbox.'
	   });
	   this.propertyBox.addProperty(this.tabId, 1, 0, 'label', 'Textbox', this, {
	   		label: 'Label',
			help: 'Sets the label of the checkbox.'
	   });
    };
    
    this.setProperty = function(property, value){
        // Changes the property of  this object setting it to value.
        switch (property) {
			case 'name':
				this.checkbox.name = value;
				break;
			case 'label':
				this.label.innerHTML = value;
				break;
            default:
                break;
        }
    };
    
    this.getProperty = function(property){
        // Gets the property of  this object
        switch (property) {
			case 'name':
				return this.checkbox.name;
				break;
            case 'label':
                return this.label.innerHTML;
                break;
            default:
                break;
        }
    };
    
    this.JSON = function(){
        var EO_JSON = {
			name: this.getProperty('name'),
			label: this.getProperty('label')
        };
        return EO_JSON;
    }
	
	this.HTML = function(){
		var html = "<div style=\"position: absolute; left: " +this.getProperty('left') + "; top: "+ this.getProperty('top') + "\"><input id=\"" + this.checkbox.id + "\" type=\"checkbox\" name=\"" + this.getProperty('name') +  "\" />" +
		"<label for=\"" + this.checkbox.id + "\">" + this.getProperty('label') + "</label></div>";
		return html;
	}
    
    this.help = "You can select several options in the same group when using a checkbox button.";
	
	this.objectList = new Array();
	this.selectorList = new Array();
	
    this.init = function(){
		this.objectList.push('div');
		this.selectorList.push('label');
		this.selectorList.push('checkbox'); 
		       
		var div = document.createElement('div');
		this.div = div;
		
		var checkbox = document.createElement('input');
		checkbox.type = 'checkbox';	
		checkbox.readOnly = true;
		checkbox.disabled = true;	
		checkbox.style.cursor = 'move'	
		this.checkbox = checkbox;
		
		var label = document.createElement('label');	
		label.innerHTML = 'Insert your text here.';
		label.style.zIndex = '1';
		label.style.cursor = 'move'
		this.label = label;
		
		div.appendChild(checkbox);
		div.appendChild(label);
    }
}

